package com.company;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

/**
 * @author jrue
 * @version 1.0
 * @date 2020/3/22 18:54
 */
public class Main44 {

    public static int mapXIndex = 0;
    public static int mapYIndex = 0;

    public static boolean judgeMap(boolean[][] visited,int a,int b) {

        for (int i = 0; i <= visited.length - a ; i++) {
            for (int j = 0; j <= visited[i].length - b; j++) {
                if (!visited[i][j]) {
                    boolean flag = true;
                    for (int k = i; k < i + a ; k++) {
                        for (int q = j; q < j + b; q++) {
                            if (visited[k][q]) {
                                flag = false;
                                break;
                            }
                        }
                    }
                    if (flag) {
                        mapXIndex = i;
                        mapYIndex = j;
                        return true;
                    }
                }
            }
        }

        return false;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        if (a > n && b > m) {
            System.out.println(0);
            return;
        }

        int[][] map = new int[n][m];
        int[][] value = new int[n][m];
        for (int i = 0; i < map.length; i++) {
            for (int j = 0; j < map[i].length; j++) {
                map[i][j] = sc.nextInt();
            }
        }

        for (int i = 0; i <= map.length - a; i++) {
            for (int j = 0; j <= map[i].length - b; j++) {
                int count = 0;
                int minValue = map[i][j];

                for (int k = i; k < i + a; k++) {
                    for (int q = j; q < j + b; q++) {
                        minValue = Math.min(minValue,map[k][q]);
                    }
                }
                for (int k = i; k < i + a; k++) {
                    for (int q = j; q < j + b; q++) {
                        count += (map[k][q] - minValue);
                    }
                }

                value[i][j] = count;
            }
        }

        boolean[][] visited = new boolean[n][m];

        int k = 0;
        List<String> s = new ArrayList<>();
        while (judgeMap(visited,a,b)) {
            k++;
            int minValueIndexX = 0;
            int minValueIndexY = 0;
            int minValue = map[minValueIndexX][minValueIndexY];
            for (int i = 0; i < map.length; i++) {
                for (int j = 0; j < map[i].length; j++) {
                    if (!visited[i][j] && value[i][j] < minValue) {
                        minValue = value[i][j];
                        minValueIndexX = i;
                        minValueIndexY = j;
                    }
                }
            }
            s.add((minValueIndexX + 1) + " " + (minValueIndexY + 1) + " " + (minValue));
            for (int i = minValueIndexX; i < minValueIndexX + a; i++) {
                for (int j = minValueIndexY; j < minValueIndexY + b; j++) {
                    visited[i][j] = true;
                }
            }
        }

        System.out.println(k);
        for (int i = 0; i < s.size(); i++) {
            System.out.println(s.get(i));
        }


    }

}
